import { Dispatch } from "redux";
import { IAction } from "store";

const HOME_UPDATE_COUNT = "HOME_UPDATE_COUNT";

export type SetPageTitle = (data: any) => {
  type: string;
  payload: any;
};
export type AsyncUpdateCount = (
  count: number
) => (dispatch: Dispatch<IAction>) => void;

export const setPageTitle: SetPageTitle = (data) => {
  return {
    type: "TEST",
    payload: data,
  };
};

export const asyncUpdateCount: AsyncUpdateCount = (count) => (dispatch) => {
  setTimeout(() => {
    const newCount = count + 1;
    dispatch({
      type: HOME_UPDATE_COUNT,
      payload: newCount,
    });
  }, 1000);
};
